package cn.org.eshow.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 提现账号表表
 */
@Entity
@Table(name = "withdraw_account")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class WithdrawAccount extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;//提现账号ID

    @Column(name = "add_time", nullable = false, length = 0)
    private Date addTime = new Date();//添加时间

    @Column(name = "update_time", nullable = false, length = 0)
    private Date updateTime = new Date();//更新时间

    @Column(length = 30, name = "bank_name")
    private String bankName;//银行名称

    @Column(length = 20, name = "bank_card_no")
    private String bankCardNo;//银行卡号

    @Column(length = 20, name = "bank_account_name")
    private String bankAccountName;//银行开户人姓名

    @Column(length = 100, name = "alipay_name")
    private String alipayName;//支付宝名称

    @Column(length = 30, name = "alipay_account")
    private String alipayAccount;//支付宝账号

    @Column(length = 100, name = "wechat_openid")
    private String wechatOpenID;//微信OpenID

    @Column(length = 30, name = "wechat_unionid")
    private String wechatUnionID;//微信UnionID

    @Column(length = 30, name = "wechat_nickname")
    private String wechatNickname;//微信昵称

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;//用户

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getBankCardNo() {
        return bankCardNo;
    }

    public void setBankCardNo(String bankCardNo) {
        this.bankCardNo = bankCardNo;
    }

    public String getBankAccountName() {
        return bankAccountName;
    }

    public void setBankAccountName(String bankAccountName) {
        this.bankAccountName = bankAccountName;
    }

    public String getAlipayName() {
        return alipayName;
    }

    public void setAlipayName(String alipayName) {
        this.alipayName = alipayName;
    }

    public String getAlipayAccount() {
        return alipayAccount;
    }

    public void setAlipayAccount(String alipayAccount) {
        this.alipayAccount = alipayAccount;
    }

    public String getWechatOpenID() {
        return wechatOpenID;
    }

    public void setWechatOpenID(String wechatOpenID) {
        this.wechatOpenID = wechatOpenID;
    }

    public String getWechatUnionID() {
        return wechatUnionID;
    }

    public void setWechatUnionID(String wechatUnionID) {
        this.wechatUnionID = wechatUnionID;
    }

    public String getWechatNickname() {
        return wechatNickname;
    }

    public void setWechatNickname(String wechatNickname) {
        this.wechatNickname = wechatNickname;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", this.id)
                .append("addTime", this.addTime)
                .append("updateTime", this.updateTime)
                .append("bankName", this.bankName)
                .append("user", this.user)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        WithdrawAccount pojo = (WithdrawAccount) o;
        if (addTime != null ? !addTime.equals(pojo.addTime) : pojo.addTime != null)
            return false;
        if (updateTime != null ? !updateTime.equals(pojo.updateTime) : pojo.updateTime != null)
            return false;
        if (bankName != null ? !bankName.equals(pojo.bankName) : pojo.bankName != null)
            return false;
        if (user != null ? !user.equals(pojo.user) : pojo.user != null)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result;
        result = (id != null ? id.hashCode() : 0);
        result = 31 * result + (addTime != null ? addTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (bankName != null ? bankName.hashCode() : 0);
        result = 31 * result + (user != null ? user.hashCode() : 0);
        return result;
    }
}
